package com.dk.service.impl;

import com.dk.Vo.ArticleVo;
import com.dk.mapper.ArticleMapper;
import com.dk.pojo.Article;
import com.dk.pojo.UUser;
import com.dk.service.ArticleServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleServiceI {

    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public List<ArticleVo> getInfoServer(String uname) {
        return articleMapper.getInfoServer(uname);
    }

    @Override
    public void saveById(Article article, UUser uUser) {
        article.setArtAuthor(uUser.getUname());
        article.setArtDate(new Date());
        article.setExamine(3);
        articleMapper.insertSelective(article);
    }

    @Override
    public Article getUpdateById(Integer artId) {
        return articleMapper.selectByPrimaryKey(artId);
    }

    @Override
    public void updateById(Article article) {
        articleMapper.updateByPrimaryKeySelective(article);
    }

    @Override
    public void deleteById(Integer artId) {
        articleMapper.deleteByPrimaryKey(artId);
    }

    @Override
    public List<ArticleVo> getInfoServers() {
        return articleMapper.getInfoServers();
    }

    @Override
    public Article getUpdateInfo(Integer artId) {
        return articleMapper.selectByPrimaryKey(artId);
    }

    @Override
    public void updateByIdd(Article article) {
        articleMapper.updateByPrimaryKeySelective(article);
    }
}
